public class Test {

    public String toLowerCase(String s) {
        if(s == null){
            return null;
        }

        String ret = "";
        for(int i = 0; i < s.length(); i++){
            char ch = s.charAt(i);
            if(Character.isLetter(ch)){
                if(!Character.isLowerCase(ch)){
                    ch = (char)(ch + 32);
                }
            }
            ret += ch;
        }

        return ret;
    }

    public static void main(String[] args) {

    }

    public static void main4(String[] args) {
        StringBuilder stringBuilder = new StringBuilder("abcd");
        // stringBuilder.append(10);
        StringBuilder delete = stringBuilder.delete(0,3);
        System.out.println(stringBuilder);
        System.out.println(delete);
    }

    public static void main3(String[] args) {
        StringBuffer str = new StringBuffer("hello");
        str.append("world");
        System.out.println(str);

        str.setCharAt(0, 'H');
        System.out.println(str);

        str.insert(5, ' ');
        System.out.println(str);

        str.deleteCharAt(0);
        System.out.println(str);

        str.delete(0,5);
        System.out.println(str);

        str.reverse();
        System.out.println(str);

    }

    public static void main2(String[] args) {
        /*String str = "hello";
        str += "world";
        System.out.println(str);*/
        long start = System.currentTimeMillis();
        String s = "";
        for(int i = 0; i < 10000; ++i){
            s += i;
        }
        long end = System.currentTimeMillis();
        System.out.println(end - start);

        start = System.currentTimeMillis();
        StringBuffer sbf = new StringBuffer("");
        for(int i = 0; i < 10000; ++i){
            sbf.append(i);
        }
        end = System.currentTimeMillis();
        System.out.println(end - start);

        start = System.currentTimeMillis();
        StringBuilder sbd = new StringBuilder();
        for(int i = 0; i < 10000; ++i){
            sbd.append(i);
        }
        end = System.currentTimeMillis();
        System.out.println(end - start);
    }

    public static void main1(String[] args) {
        Test test = new Test();
        String ret = test.toLowerCase("Hello");
        System.out.println(ret);
    }
}
